import { axios } from '@/utils/request'

/**
 * 查询流程列表
 * @param query
 * @returns {*}
 */
export function pageProcess(query) {
  return axios({
    url: '/workflow/process/page',
    method: 'get',
    params: query
  })
}

/**
 * 查询OA流程部署关联表单信息
 * @param query
 * @returns {*}
 */
export function getProcessForm(query) {
  return axios({
    url: '/workflow/process/getProcessForm',
    method: 'get',
    params: query
  })
}

/**
 * 部署OA流程实例
 * @param processDefId
 * @param data
 * @returns {*}
 */
export function startProcess(processDefId, data) {
  return axios({
    url: '/workflow/process/start/' + processDefId,
    method: 'post',
    data: data
  })
}

/**
 * 部署自定义业务流程实例
 * @param dataId
 * @param selectFlowId
 * @param serviceName
 * @param data
 * @returns {*}
 */
export function startByDataId(dataId,customFromId, serviceName, data) {
  return axios({
    url: '/workflow/process/startByDataId/' + dataId + '/' + customFromId + '/'+ serviceName,
    method: 'post',
    data: data
  })
}

/**
 * 查询当前节点是否是属于退回或驳回的第一个发起人节点,业务数据dataid
 * @param dataId
 * @param data
 * @returns {*}
 */
export function isFirstInitiator(dataId,data) {
  return axios({
    url: '/workflow/task/isFirstInitiator/' + dataId,
    method: 'post',
    data: data
  })
}

/**
 * 根据当前服务名查询自定义业务单
 * @param query
 * @returns {*}
 */
export function getProcess(query) {
  return axios({
    url: '/workflow/process/getProcess',
    method: 'get',
    params: query
  })
}

/**
 * 删除自定义业务任务关联表与流程历史表,以便可以重新发起流程
 * @param dataId 业务表id
 * @param data
 * @returns {*}
 */
export function deleteActivityAndJoin(dataId,data) {
  return axios({
    url: '/workflow/task/deleteActivityAndJoin/' + dataId,
    method: 'post',
    data: data
  })
}

/**
 * 删除流程实例
 * @param ids
 * @returns {*}
 */
export function delProcess(ids) {
  return axios({
    url: '/workflow/process/instance/' + ids,
    method: 'delete'
  })
}

/**
 * 获取流程图
 * @param processDefId
 * @returns {*}
 */
export function getBpmnXml(processDefId) {
  return axios({
    url: '/workflow/process/bpmnXml/' + processDefId,
    method: 'get'
  })
}

/**
 * 根据流程实例id查询流程详情
 * @param query
 * @returns {AxiosPromise}
 */
export function detailProcess(query) {
  return axios({
    url: '/workflow/process/detail',
    method: 'get',
    params: query
  })
}


/**
 * 根据业务表id查询流程详情
 * @param query
 * @returns {AxiosPromise}
 */
export function detailProcessByDataId(query) {
  return axios({
    url: '/workflow/process/detailByDataId',
    method: 'get',
    params: query
  })
}

/**
 * 钉钉流程转bpmn
 * @param data
 * @returns {*}
 */
export function dingdingToBpmn(data) {
  return axios({
    url: '/workflow/process/ddtobpmn',
    method: 'post',
    data: data
  })
}

/**
 * 判断流程是否结束了,用在消息点击里判断
 * @param query
 * @returns {*}
 */
export function processIscompleted(query) {
  return axios({
    url: '/workflow/process/iscompleted',
    method: 'get',
    params: query
  })
}

/**
 * 我的发起的流程
 * @param query
 * @returns {*}
 */
export function listOwnProcess(query) {
  return axios({
    url: '/workflow/process/ownList',
    method: 'get',
    params: query
  })
}

/**
 * 所有发起的流程
 * @param query
 * @returns {*}
 */
export function listAllProcess(query) {
  return axios({
    url: '/workflow/process/allList',
    method: 'get',
    params: query
  })
}

/**
 * 我待办的流程
 * @param query
 * @returns {*}
 */
export function listTodoProcess(query) {
  return axios({
    url: '/workflow/process/todoList',
    method: 'get',
    params: query
  })
}

/**
 * 我待签的流程
 * @param query
 * @returns {*}
 */
export function listClaimProcess(query) {
  return axios({
    url: '/workflow/process/claimList',
    method: 'get',
    params: query
  })
}

/**
 * 我已办的流程
 * @param query
 * @returns {*}
 */
export function listFinishedProcess(query) {
  return axios({
    url: '/workflow/process/finishedList',
    method: 'get',
    params: query
  })
}

/**
 * 查询流程抄送列表
 * @param query
 * @returns {*}
 */
export function listCopyProcess(query) {
  return axios({
    url: '/workflow/process/copyList',
    method: 'get',
    params: query
  })
}

/**
 * 查询流程我的抄送列表
 * @param query
 * @returns {*}
 */
export function listMyCopyProcess(query) {
  return axios({
    url: '/workflow/process/myCopyList',
    method: 'get',
    params: query
  })
}

/**
 * 删除抄送
 * @param copyIds
 * @returns {*}
 */
export function delCopy(copyIds) {
  return axios({
    url: '/workflow/process/delCopy/' + copyIds,
    method: 'delete'
  })
}

/**
 * 抄送人已读状态
 * @param parameter
 * @returns {*}
 */
export function updateCcReaded(parameter) {
  return axios({
    url: '/workflow/process/updateViewStatust',
    method:'get',
    params: parameter
  })
}

/**
 * 取消申请
 * @param data
 * @returns {*}
 */
export function stopProcess(data) {
  return axios({
    url: '/workflow/task/stopProcess',
    method: 'post',
    data: data
  })
}
